refactor: codebase simplification across 6 phases#106
Merged
shrimalmadhur merged 4 commits intomainfrom Mar 28, 2026
Merged
Conversation
Phase 1: Remove unused exports (SLACK_MAX_MSG_LEN, escapeSlackText, AgentConfig) Phase 2: Deduplicate shared constants (inputClasses, formatTokens, DENIED_ENV_KEYS) Phase 3: Merge duplicate timeline builders, extract metadata helper in claude module Phase 4: Extract notification upsert helper with ON CONFLICT, add MCP PATCH validation Phase 5: Decompose 990-line settings page into 3 self-contained section components Phase 6: Split 1,536-line pipeline.ts into 4 modules (prompts, claude-runner, helpers, orchestrator) - Settings page: 990 → 35 lines (sections extracted to components/settings/) - Pipeline: 1,536 → 2 lines re-export (logic split into pipeline/ subdirectory) - Timeline builders: merged buildTimeline + buildSubAgentTimeline into one parameterized function - Notification upserts: 5 inline select-then-branch patterns → shared ON CONFLICT helper - New Drizzle migration: unique constraint on notification_configs.channel - New tests: formatTokens utility, timeline builder regression tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The unique constraint on notification_configs.channel and the associated Drizzle migration are out of scope for a pure code simplification task. Rewrote the notification-config helper to use select-then-update/insert instead of ON CONFLICT, so no schema change is needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0a25619 to
a30e9b2
Compare
…components - Extract shared `parseBody` helper for Zod validation (replaces 9 identical safeParse+error blocks across API routes) - Deduplicate claude session module: move `summarizeToolInput` and `extractMetadata` to shared session-utils, reuse `aggregateTokensFromEntries` in session-reader instead of reimplementing token aggregation - Extract `removeWorktree`/`forceRemoveWorktree`/`pruneWorktrees` helpers (replaces 4 duplicated git worktree cleanup blocks) - Consolidate `settingsInputClasses` into shared form-classes.ts (3 components) - Move inline MCP server update schema to src/lib/validations/mcp.ts - Remove unused API helpers (jsonResponse, notFound, conflict, badRequest) and replace tests with parseBody coverage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix extractSessionMetadata direction: reverse entries in session-reader to preserve "most recent values" behavior from the old backward walk - Restore aggregateTokensFromFile fast-path: use string pre-checks to skip JSON parsing for lines without usage data (perf hot path) - Extract duplicated SlackIcon/TelegramIcon SVGs to shared source-icons component (was copy-pasted in issues/page.tsx and issues/[id]/page.tsx) - Return config id from upsertNotificationConfig and telegram POST response to maintain API backward compatibility Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive codebase cleanup and simplification across 6 phases:
SLACK_MAX_MSG_LEN,escapeSlackText,AgentConfig)inputClasses,formatTokens,DENIED_ENV_KEYS)ON CONFLICT, add MCP PATCH validationKey metrics
components/settings/)pipeline/subdirectory)buildTimeline+buildSubAgentTimelineinto one parameterized functionON CONFLICThelpernotification_configs.channelformatTokensutility, timeline builder regression testsTest plan
bun run tsc --noEmitpassesbun test build-timelineandbun test format🤖 Generated with Claude Code